<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="/Static/Css/reset.css" />
<link rel="stylesheet" type="text/css" href="/Static/Css/zh-cn-system.css" />
<link rel="stylesheet" type="text/css" href="/Static/Css/table_form.css" />
<script src="/Public/js/jquery.min.js"></script>
<script src="/Public/js/jquery.form.js"></script>
<script src="/Public/js/main.js"></script>
<script type="text/javascript" src="/Public/artDialog/jquery.artDialog.js?skin=default"></script>
<script type="text/javascript" src="/Public/artDialog/plugins/iframeTools.js"></script>
</head>
<body>

<script type="text/javascript" src="/Public/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="/Public/ToolTip.js"></script>

<div class="subnav">
  <div class="explain-col" style="position: relative;" id="add-list">
    <form name="addForm" id="addForm" method="POST" action="/index.php/customer/add">
      <table class="add-table">
        <tr>
          <td width="240">
            学员姓名：&nbsp;<input type="text" name="data[name]" id="name" size="20"  value="<?php echo ($_GET['name']); ?>" class="input-text" placeholder="请输入学员姓名" />
          </td>
          <td width="240">
            联系电话：&nbsp;<input type="text" name="data[phone]" id="phone" size="20"  value="<?php echo ($_GET['phone']); ?>" class="input-text" placeholder="请输入联系方式" />
          </td>
          <td width="240">
            &nbsp;QQ号码：<input type="text" name="data[qq]" id="qq" size="20"  value="<?php echo ($_GET['qq']); ?>" class="input-text" placeholder="请输入QQ号码" />
          </td>
          <td>
            课程项目：
            <select name="data[rourse]" id="rourse">
              <option value="0">请选择所属分组</option>
              <?php $_result=get_course_list();if(is_array($_result)): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vo["id"]); ?>"  ><?php echo ($vo["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
            </select>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            课程详细：<input type="text" name="rourse_text" id="rourse_text" alue="<?php echo ($_GET['rourse_text']); ?>" class="input-text" placeholder="" style="width:300px;" />
          </td>
        </tr>
        <tr>
          <td>
            所属顾问：
            <select name="data[counselor]" id="counselor">
              <option value="0">请选择所属顾问</option>
              <?php $_result=get_admin_list();if(is_array($_result)): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vo["id"]); ?>"  ><?php echo ($vo["username"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
            </select>
          </td>
          <td>
            意向级别：
            <select name="data[level]" id="level">
              <option value="0">请选择级别</option>
              <?php $_result=levelArr();if(is_array($_result)): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($key); ?>"  ><?php echo ($vo); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
            </select>
          </td>
          <td>
            详细级别：<input type="text" name="data[level_text]" id="level_text" size="20"  value="<?php echo ($_GET['level_text']); ?>" class="input-text" />
          </td>
          <td></td>
        </tr>
        <tr>
          <td>
            咨询方式：
            <select name="data[source]" id="source">
              <option value="0">请选择咨询方式</option>
              <?php $_result=get_source_list();if(is_array($_result)): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vo["id"]); ?>"  ><?php echo ($vo["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
            </select>
          </td>
          <td>
            &nbsp;&nbsp;&nbsp;合作方：
            <input type="text" name="data[partner]" id="partner" size="20"  value="<?php echo ($_GET['partner']); ?>" class="input-text" placeholder="请输入合作方" />
          </td>
          <td>
            跟进时间：<input type="text" name="talk_time2" id="talk_time2" size="20" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})"  value="" class="input-text Wdate" />
          </td>
          <td></td>
        </tr>
        <tr>
          <td colspan="4">
            <input type="submit" value=" 添加学员 " class="button"  style=" position: relative; top:50%; left:50%;" />
            <input type="button" value=" 隐藏添加 " class="button" id="hide-add-button"  style=" position: relative; top:50%; left:50%;" />
          </td>
        </tr>
      </table>

    </form>
  </div>
  <div class="explain-col" style="position: relative; margin-top: 10px;">
    <form name="searchForm" id="searchForm" method="GET" action="">
      搜索：
      <input type="text" name="keyword" id="keyword" size="30" placeholder="请输入关键词"  value="<?php echo ($_GET['keyword']); ?>" class="input-text"  style="height:20px; width:120px; color:#999" />

      <select name="counselor" id="counselor" onchange="searchForm.submit()">
        <option value="0">请选择所属顾问</option>
        <?php $_result=get_admin_list();if(is_array($_result)): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vo["id"]); ?>" <?php echo selected($vo['id'],$_GET['counselor']);?>><?php echo ($vo["username"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
      </select>
      <select name="source" id="source" onchange="searchForm.submit()">
        <option value="0">请选择咨询方式</option>
        <?php $_result=get_source_list();if(is_array($_result)): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vo["id"]); ?>" <?php echo selected($vo['id'],$_GET['source']);?>><?php echo ($vo["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
      </select>
      <select name="level" id="level" onchange="searchForm.submit()" style="width: 123px;">
        <option value="0">请选择级别</option>
        <?php $_result=levelArr();if(is_array($_result)): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($key); ?>" <?php echo selected($key,$_GET['level']);?> ><?php echo ($vo); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
      </select>
      <select name="talk_time" id="talk_time" onchange="searchForm.submit()" >
            <option value="0" selected="selected">上次跟进时间</option>
            <option value="1" <?php if(($_GET['talk_time']) == "1"): ?>selected="selected"<?php endif; ?> />今天</option>
            <option value="2" <?php if(($_GET['talk_time']) == "2"): ?>selected="selected"<?php endif; ?> />昨天</option>
            <option value="3" <?php if(($_GET['talk_time']) == "3"): ?>selected="selected"<?php endif; ?> />本周</option>
            <option value="4" <?php if(($_GET['talk_time']) == "4"): ?>selected="selected"<?php endif; ?> />上周</option>
            <option value="5" <?php if(($_GET['talk_time']) == "5"): ?>selected="selected"<?php endif; ?> />本月</option>
            <option value="6" <?php if(($_GET['talk_time']) == "6"): ?>selected="selected"<?php endif; ?> />上月</option>
            <!-- <option value="5" <?php if(($_GET['talk_time']) == "7"): ?>selected="selected"<?php endif; ?> />自定</option> -->
      </select>


      <!-- 签约时间：
      <input type="text" name="start_date" id="start_date" size="30" placeholder="开始时间"  value="<?php echo ($_GET['start_date']); ?>" class="input-text Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="readonly" style="height:20px; width:120px; color:#999" />-
      <input type="text" name="end_date" id="end_date" size="30" placeholder="结束时间"  value="<?php echo ($_GET['end_date']); ?>" class="input-text Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="readonly" style="height:20px; width:120px; color:#999" /> -->

      <input type="submit" value=" 搜索 " class="button" id="searchButton" />
    </form>
    <div class="content-menu" style="position: absolute; right: 30px;top: 5px; display: none;"> <a href="javascript:openWinBox('/index.php/customer/add','添加新客户',850);" class="add fb"><em>添加新客户</em></a> </div>
  </div>
</div>
<!--subnav-->
<div class="pad-lr-10">
  <form name="myform" id="myform" action="" method="post">
    <div class="table-list">
      <table width="100%" cellspacing="0">
        <thead>
          <tr>
            <th width="50" align="center">选择</th>
            <th align="center">录入时间</th>
            <th align="center">所属顾问</th>
            <th align="center">咨询方式</th>
            <th align="center">意向级别</th>
            <th align="center">详细级别</th>
            <th align="center">学员名称</th>
            <th align="center">所在地</th>
            <th align="center">课程项目</th>
            <th align="center">详细课程</th>
            <th align="center">联系电话</th>
            <th align="center">上次跟进</th>
            <th align="center">剩余天数</th>
            <th align="center">下次跟进</th>
            <th align="center">跟进次数</th>
            <th align="center" width="160">操作</th>
          </tr>
        </thead>
        <tbody  id="list">
          <?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr id="list-<?php echo ($vo["id"]); ?>">
              <td align="center"><input type="checkbox" name="idArr[]" value="<?php echo ($vo["id"]); ?>"></td>
              <td align="center"><?php echo (date('Y-m-d H:i:s',$vo["create_time"])); ?></td>
              <td align="center"><?php echo (get_counselor_name($vo["counselor"])); ?></td>
              <td align="center"><?php echo (get_source_name($vo["source"])); ?></td>
              <td align="center"><?php echo (levelArr($vo["level"])); ?></td>
              <td align="center"><?php echo ($vo["level_text"]); ?></td>
              <td align="center"><?php echo ($vo["name"]); ?></td>
              <td align="center"><?php echo ($vo["address"]); ?></td>
              <td align="center"><?php echo (get_course_name($vo["course"])); ?></td>
              <td align="center"><?php echo ($vo["course_text"]); ?></td>
              <td align="center"><?php echo ($vo["phone"]); ?></td>
              <td align="center"><?php echo (date('Y-m-d H:i:s',$vo["talk_time"])); ?></td>
              <td align="center"><?php echo time_diff($vo['talk_time'],$vo['talk_time2']);?></td>
              <td align="center"><?php echo (date('Y-m-d H:i:s',$vo["talk_time2"])); ?></td>
              <td align="center"><?php echo ($vo["talk_num"]); ?></td>
              <td align="center">
                <a href="javascript:openWinBox('/index.php/customer/add/id/<?php echo ($vo["id"]); ?>','客户信息',800,480)" >【修改】</a>
                <a href="javascript:openWinBox('/index.php/customer/add_record/id/<?php echo ($vo["id"]); ?>','追加跟进内容')" >【追加跟进内容】</a>
              </td>
            </tr><?php endforeach; endif; else: echo "" ;endif; ?>
        </tbody>
      </table>
      <div class="btn">
        <div id="pages"><?php echo ($page); ?></div>
         <input name="submit" id="checkall" type="button" class="button" value="全选/反选">
         <input name="submit" type="button" class="button" value="放入公共池"  onclick="return owned();">
         <input name="submit" type="button" class="button" value="删除所选"  onclick="return deleteConfirm();">
      </div>
    </div>
  </form>
</div>
</body>
</html>
<script type="text/javascript">
$(document).ready(function(e) {


  //全反选
  $("#checkall").click(function(){
    $("input[name=idArr[]]").each(function(){
      if(this.checked == false)
        this.checked = true;
      else
          this.checked = false;
    });
  });

  $("#hide-add-button").click(function(){
    $("#add-list").hide();
    $(".content-menu").show();
  })

});

function deleteConfirm() {
    art.dialog({
        content: '确定删除所选数据吗？',
        ok: function() {
            del();
            return true;
        },
        cancelVal: '取消',
        cancel: true
    });
}

function del() {
    var idArr = Array();
    var i = 0;
    var id;
    $("input[name='idArr[]']").each(function() {
        if (this.checked == true) {
            idArr[i] = $(this).val();
            i++;
        }
    });
    jQuery.get('/index.php/customer/del', encodeURI('id=' + idArr), success, 'json');

    function success(data) {
        if (data.status == 1) {
            window.top.art.dialog({
                id: 'TNCICC',
                content: data.info,
                time: 1,
                icon: 'succeed'
            });
            setTimeout(function() {
              window.location.reload();
            }, 1000);
        } else {
            window.top.art.dialog({
                id: 'TNCICC',
                content: data.info,
                time: 1,
                icon: 'warning'
            });
        }

    }
}

</script>


<script type="text/javascript">
$(document).ready(function(e) {

  $('#addForm').ajaxForm({
      beforeSubmit:  checkForm,
      success:       complete,
      dataType: 'json'
  });

  function checkForm(){
    var name = $("#name").val();
    var role_id = $("#role_id").val();

    if( name=='' ){
      art.dialog({id:'TNCICC',content: '请输入学员姓名',time: 2,icon:'warning'});
      $('#name').focus();
      return false;
    }

    if(role_id==0){
      art.dialog({id:'TNCICC',content: '请选择所属顾问',time: 2,icon:'warning'});
      return false;
    }
    return true;
  }

  var origin = $.artDialog.open.origin;
  function complete(data){
    if(data.status==1){
      art.dialog({id:'TNCICC',content: data.info,time: 1,icon:'succeed'});
      setTimeout(function(){origin.location.reload();closeWin()},1500);
    }else{
      art.dialog({id:'TNCICC',content: data.info,time: 1,icon:'warning'});
    }

  }

});




function owned() {
    art.dialog({
        content: '确定将所选择的学员放入公共池吗？',
        ok: function() {
            to_owned();
            return true;
        },
        cancelVal: '取消',
        cancel: true
    });
}

function to_owned() {
    var idArr = Array();
    var i = 0;
    var id;
    $("input[name='idArr[]']").each(function() {
        if (this.checked == true) {
            idArr[i] = $(this).val();
            i++;
        }
    });
    jQuery.get('/index.php/customer/owned/status/0', encodeURI('id=' + idArr), success, 'json');

    function success(data) {
        if (data.status == 1) {
            window.top.art.dialog({
                id: 'TNCICC',
                content: data.info,
                time: 1,
                icon: 'succeed'
            });
            setTimeout(function() {
              window.location.reload();
            }, 1000);
        } else {
            window.top.art.dialog({
                id: 'TNCICC',
                content: data.info,
                time: 1,
                icon: 'warning'
            });
        }

    }
}

</script>